<div align="center"><h1>Add a new site</h1></div>
<form name="Add" method="get" action="addsite.php">
<table width="40%" style="margin-left: 30%" border="1" cellspacing="1" cellpadding="0">
<tr>
	<td>
		<table width="100%" border="0" cellspacing="0" cellpadding="10px">
			<tr>
				<td align="right"><strong>Hostname: </strong></td>
				<td align="left"><input name=url type="text" id="url"></td>
				
			</tr>
			<tr>
				<td align="right"><strong>Status:</strong></td>
				<td align="left">
					<select name="pause" id="pause">
						<option value="0">Enable</option>
						<option value="1">Disable</option>
					</select>
				</td>
			</tr>
			<tr>
				<td align="center" colspan="2"><input type="submit" name="Submit" value="Submit"></td>				
			</tr>
		</table>
	</td>
</tr>
</table>
</form>
<div align="center"><?php if(isset($_GET['message'])) echo $_GET['message'];?></div><br />
<div align="center"><a href="sites.php">Back to Site Management</a></div>
<div align="center"><a href="index.php">Back to Main Menu</a></div>"
<?php
	require_once('config.php');
	require_once('db.php');
	$sql = "INSERT INTO sites(hostname, pause) VALUES(";
	//echo $sql;
	if (isset($_GET["url"]))
	{
		$url = $_GET["url"];
		$sql .= "'$url'";
	}
	else
	{
		$sql .= "''";
	//	echo "This is else " . $url;
		return;
	}
	if (isset($_GET["pause"]))
	{
		$pause = $_GET["pause"];
		$sql .= ", '$pause')";
	}
	else
	{
		$sql .= ", '0'";
		$sql .= ")";
	}
	$link = connectdb($servername,$dbname,$dbusername,$dbpassword);
	if(!$link)
 	{
 		die("Could not connect to MySQL");
 	}	
	$rt=mysql_query($sql);
 	// if successfully updated.
	if($rt){
		$message = urldecode("<b>Add successfully</b>");
		close($link);	
		header("Location: sites.php?message=" . $message);		
	}
	else {
		$message = urldecode("There is an MySQL error occurred: <b>" . mysql_error($link) . "</b>");
		close($link);	
		header("Location: addsite.php?message=" . $message);	
	}
	
 ?>
	